package com.foreverwin.mes.common.enums;

import java.text.MessageFormat;

/**
 * @author Ervin Chen
 * @date 2020/2/5 14:50
 */
public enum HandleEnum {

    /**资源*/
    RESOURCE( "ResourceBO:", "ResourceBO:{0},{1}" ),

    /**库存*/
    INVENTORY( "InventoryBO:", "InventoryBO:{0},{1}" ),

    /**车间作业控制*/
    SFC( "SFCBO:", "SFCBO:{0},{1}" ),

    /**工序*/
    OPERATION( "OperationBO:", "OperationBO:{0},{1},{2}" ),

    /**物料*/
    ITEM( "ItemBO:", "ItemBO:{0},{1},{2}" ),

    /**物料组*/
    ITEM_GROUP( "ItemGroupBO:", "ItemGroupBO:{0},{1}" ),

    /**存储地点*/
    STORAGE_LOCATION( "StorageLocationBO:", "StorageLocationBO:{0},{1}" ),

    /**原因代码*/
    REASON_CODE( "ReasonCodeBO:", "ReasonCodeBO:{0},{1},{2}" ),

    /**工单*/
    SHOP_ORDER( "ShopOrderBO:", "ShopOrderBO:{0},{1}" ),

    /**物料清单*/
    BOM( "BOMBO:", "BOMBO:{0},{1},{2},{3}" ),

    /**用户*/
    USER( "UserBO:", "UserBO:{0},{1}" ),

    /**状态*/
    STATUS( "StatusBO:", "StatusBO:{0},{1}" ),

    /**数据收集组*/
    DC_GROUP( "DcGroupBO:", "DcGroupBO:{0},{1},{2}" ),

    /**供应商*/
    VENDOR( "VendorBO:", "VendorBO:{0},{1}" ),

    /**设备库存*/
    RESOURCE_INVENTORY( "ResourceInventoryBO:", "ResourceInventoryBO:{0},{1},{2},{3},{4}" ),

    /**设备库存日志*/
    RESOURCE_INVENTORY_LOG( "ResourceInventoryLogBO:", "ResourceInventoryLogBO:{0},{1},{2},{3},{4}" ),

    /**库存接收确认*/
    INVENTORY_RECEIVE_CONFIRM( "InventoryReceiveConfirmBO:", "InventoryReceiveConfirmBO:{0},{1}" ),

    /**在制不良录入*/
    DEFECTIVE_RECORDS_OF_WIP( "DefectiveRecordsOfWipBO:", "DefectiveRecordsOfWipBO:{0},{1},{2}" ),

    /**库存不良录入*/
    BAD_ENTRY_OF_WSM( "BadEntryOfWsmBO:", "BadEntryOfWsmBO:{0},{1},{2}" ),

    /**成品入库确认*/
    YIELD_CONFIRM( "YieldConfirmBO:", "YieldConfirmBO:{0},{1},{2}" ),

    /**库存调拨记录*/
    INVENTORY_MOVE_LOG( "InventoryMoveLogBO:", "InventoryMoveLogBO:{0},{1},{2}" ),

    /**检验项目*/
    INSPECT_PROJECT( "InspectProjectBO:", "InspectProjectBO:{0},{1},{2},{3}" ),

    /**领料汇总*/
    MATERIAL_REQUISITION_SUMMARY( "MaterialRequisitionSummaryBO:", "MaterialRequisitionSummaryBO:{0},{1},{2},{3}" ),

    /**领料记录*/
    MATERIAL_REQUISITION_LOG( "MaterialRequisitionLogBO:", "MaterialRequisitionLogBO:{0},{1},{2},{3},{4}" ),

    /**物料耗用*/
    MATERIAL_CONSUMPTION( "MaterialConsumptionBO:", "MaterialConsumptionBO:{0},{1},{2}" ),

    /**计划订单*/
    PLANNED_ORDER( "PlannedOrderBO:", "PlannedOrderBO:{0},{1}" );

    private String prefix;
    private String pattern;
    HandleEnum( String prefix, String pattern ){
        this.prefix = prefix;
        this.pattern = pattern;
    }

    public String getHandle( String... parts ){
        return MessageFormat.format( pattern, parts );
    }

    public String getPart( String handle, int position ){
        String handleParts = handle.replace( prefix, "" );
        String[] parts = handleParts.split("," );
        if( position >= parts.length ){
            return null;
        }else{
            return parts[position];
        }
    }

    public String getPrefix(){
        return prefix;
    }
}
